<%-- 
    Document   : PatientProfile
    Created on : Apr 1, 2012, 12:41:45 PM
    Author     : David
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="edu.uta.tsrh.notes.controllers.RecordController"%>
<%@page import="edu.uta.tsrh.patient.misc.PatientRecord"%>
<%@page import="edu.uta.tsrh.patient.misc.PatientNote"%>
<a href="javascript:$.pageslide({ direction: 'right', href: 'help/addNote.html' })" class="first">help</a>
<%
    String source = (String)session.getAttribute("user");
    String patientId = request.getParameter("patient");
    String patientName = request.getParameter("patientName");
    String DOB = request.getParameter("DOB");
    PatientRecord pRecord = RecordController.getPatientRecord(patientId);
    Timestamp tm = (new Timestamp((new Date()).getTime()));
    String time = new SimpleDateFormat("EEE, MM/d/yyyy 'at' kk:mm zzzz").format(tm);
%>

<script>
    function validateForm() {
        var subject = document.getElementById("subject");
        var content = document.getElementById("note");
        var errorSpan = document.getElementById("errorspan");
        var errorString = "";
        
        if (subject.value ==null || subject.value == "")
        {
            errorString+="Subject, ";
        }
        
        if (content.value ==null || content.value == "")
        {
            errorString+="Content, ";
        }
        if(errorString == "") {
            
            return true;
        }        
        else {
            errorSpan.innerHTML = "Please enter " + errorString.substring(0, errorString.length - 2);
            return false;
            
        }
    }
</script>

<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*"%> 
<%@page import="java.util.Date"%>
<%@page import="model.PatientInfo" %>
        <div class="mainPanel">   
            <div class="panel">
                <h2>Add Note for <%= pRecord.getFirstName() %> <%= pRecord.getLastName() %></h2> 
                <form method="post" action="AddNote" onsubmit="return validateForm()">
            <ul class="infoPanel">
                <li>
                    <div><b><%= time%></b></div>
                    <input type='hidden' name='date' class='textField' value="<%=tm%>" />
                </li>
                <li>
                    <div class='name'>Subject/Title:<span style="color: red">*</span></div><br> 
                    <div class='value'><input type='text' id ="subject" name='title' class='textbox' style="width: 300px" /></div>
                </li>
                <li>
                    <div class='name'>Source:</div><br> 
                    <div class='value'><input type='text' name='source' class='textbox' value="<%=source%>" style="width: 300px" /></div>
                </li>
                <li>
                    <div class='name'>Content of the Note:<span style="color: red">*</span></div><br> 
                    <div class='value'><textarea name='content' id="note" class='textarea' style="width: 300px" ></textarea></div>
                </li>
                <li><input type="hidden" name='patient' value="<%= patientId %>" /><li>
            </ul>
                <h4><span id="errorspan" style="color:#FF0000;"></span></h4>
                <input type='submit' class="blue button linkButton" value="Save"/>
                </form>
            
           
            </div>
        </div>